package com.zy.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sun.webkit.Pasteboard;
import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;
import com.zy.entity.Customer;
import com.zy.entity.Dict;
import com.zy.service.CustomerService;
import com.zy.service.impl.CustomerServiceImpl;

/**
 * Servlet implementation class ToUpdateServlet
 */
@WebServlet("/ToUpdateServlet")
public class ToUpdateServlet extends HttpServlet {
	CustomerService cs = new CustomerServiceImpl();
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String parameter = request.getParameter("id");
		if (parameter!=null) {
			Customer customer = cs.getCustomerById(Integer.parseInt(parameter));
			request.setAttribute("customer", customer);
		}
		java.util.List<Dict> dict = cs.getDict();
		request.setAttribute("list", dict);
		
		request.getRequestDispatcher("/WEB-INF/customer/edit.jsp").forward(request, response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
